@layout("/common/_container.html"){
<div style="display: none">
    <input type="hidden" id="customerId" value="${customerId}">
    <input type="hidden" id="reservationsId" value="${reservationsId}">
    <input type="hidden" id="operationTime" value="${operationTime}">
</div>
<div id="div_print" class="print_box" style="word-break:break-all;width: 210mm;">
    <div style="word-break:break-all;font-size: 16px;color: black">
        <div class="data_row" style="text-align: center;margin-bottom: 10px;margin-top: 10px">
            <span style="font-size: 21px;font-weight: bold;display: inline-block;">咿呀口腔徐东店</span>
        </div>
        <div class="data_row" style="border-bottom: 1px solid black">
            <div style="padding-left: 6px;width: 110px;display: inline-block;">姓名:${consultantInfo.customerName}</div>
            <div style="display: inline-block;width: 205px;margin-right: -10px">
                病历号:${consultantInfo.medicalRecordNumber}
            </div>
            <div style="width: 60px;display: inline-block;">性别:${consultantInfo.sex}</div>
            <div style="width: 165px;display: inline-block;margin-right: -10px">联系电话:${consultantInfo.customerPhone}
            </div>
            <div style="width: 165px;display: inline-block;">单据号:<span id="documentNumber"></span></div>
        </div>
        <div class="data_row" style="font-weight: bold;border-bottom: 1px solid black;margin-top: 5px">
            <div style="padding-left: 10px;width: 120px;display: inline-block;">牙位</div>
            <div style="width: 140px;display: inline-block;">处置名称</div>
            <div style="width: 45px;display: inline-block;">数量</div>
            <div style="width: 100px;display: inline-block;">单位</div>
            <div style="width: 100px;display: inline-block;">单价</div>
            <div style="width: 50px;display: inline-block;">金额</div>
        </div>
        <div style="height: 175px" id="plan_box">
            <div class="data_row" style="margin-top: 5px;display: none">
                <div style="padding-left: 10px;width: 120px;display: inline-block;">
                    <div style="border-bottom: 1px solid;">
                        <div style="display: inline-block;width:55px;;border-right: 1px solid black;text-align: right"
                             id="yw_left_top"></div>
                        <div style="display: inline-block;width:55px;" id="yw_right_top"></div>
                    </div>
                    <div>
                        <div style="display: inline-block;width:55px;;border-right: 1px solid black;text-align: right"
                             id="yw_left_bottom"></div>
                        <div style="display: inline-block;width:55px;" id="yw_right_bottom"></div>
                    </div>
                </div>
                <div style="width: 140px;display: inline-block;position: relative;top: -12px;" id="disposal">
                    热牙胶+机用扩大系统磨牙
                </div>
                <div style="width: 45px;display: inline-block;position: relative;top: -12px;" id="number">1</div>
                <div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="unit">1280.00</div>
                <div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="price">1280.00</div>
                <div style="width: 100px;display: inline-block;position: relative;top: -12px;" id="amount">1280.00</div>
            </div>

        </div>
        <div class="data_row fz2" style="border-top: 1px solid black;padding-top: 2px">
            <div style="display: inline-block;width: 120px;">合计应收:<span id="hjys"></span></div>
            <div style="display: inline-block;width: 120px;">上次欠款:0.00</div>
            <div style="display: inline-block;width: 120px;">本次欠款:<span id="bcqk"></span></div>
            <div style="display: inline-block;width: 108px;">折扣率:<span id="zkl"></span></div>
            <div style="display: inline-block;width: 150px;">本次费用:<span id="bcfy"></span></div>
        </div>
        <div class="data_row fz2">
            <div style="width: 457px;display: inline-block;">收款方式:<span id="skfs"></span></div>
            <div style="display: inline-block;width: 150px;">折扣金额:<span id="zkje"></span></div>

        </div>
        <div class="data_row fz2">
            <div style="display: inline-block;width: 120px;">实收金额:<span id="ssje"></span></div>
            <div style="width: 240px;display: inline-block;">实收金额(大写):</div>
            <div style="width: 250px;display: inline-block;">备注:</div>
        </div>
        <div class="data_row fz2" style="border-top: 1px solid;padding-top: 2px">
            <div style="display: inline-block;width: 200px;">医生:<span id="doctor"></span></div>
            <div style="display: inline-block;width: 120px;">收银员:${userName}</div>
            <div style="display: inline-block;width: 120px;">医助/护士:</div>
            <div style="display: inline-block;width: 120px;">咨询师:<span id="tc"> ${consultantInfo.tcName};</span></div>
        </div>
        <div class="data_row fz2">
            <div style="vertical-align: top;width: 340px;display: inline-block;">地址:武昌区友谊大道528号千禧名苑写字楼八楼</div>
            <div style="vertical-align: top;width: 140px;display: inline-block;">电话:027-88870787</div>
            <div style="display: inline-block;width: 150px;">
                <div style="width: 225px;display: inline-block;">收款时间:<span id="nowTime"></span></div>
                <div style="display: inline-block;width: 150px;">收款单位(盖章):</div>
            </div>
        </div>
    </div>
</div>

<input name="print" type="button" id="bt" value="点击打印"/>
<script>
    var nowTime = document.getElementById('nowTime');
    var doctor = document.getElementById('doctor');
    var tc = document.getElementById('tc');
    var ssje = document.getElementById('ssje');
    var hjys = document.getElementById('hjys');
    var zkje = document.getElementById('zkje');
    var bcqk = document.getElementById('bcqk');
    var zkl = document.getElementById('zkl');
    var bcfy = document.getElementById('bcfy');
    var skfs = document.getElementById('skfs');
    var documentNumber = document.getElementById('documentNumber');
    var money_all = 0.00;
    var hjys_money = 0.00;
    var ssje_money = 0.00;
    var bcqk_money = 0.00;
    var operationTime = document.getElementById("operationTime").value;
    var reservationsId = document.getElementById("reservationsId").value;
    var customerId = document.getElementById("customerId").value;
    //页面计算赋值
    nowTime.innerText = getNowFormatDate();

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    };
    $.ajax({
        url: Feng.ctxPath + "/consultant/getTuiPrint",
        type: "post",
        data: {
            "operationTime": operationTime,
            "reservationsId": reservationsId,
            "customerId": customerId
        },
        success: function (data) {
            var arr = data;
            var plan_box = document.getElementById('plan_box');
            for (var i = 0; i < arr.length; i++) {
                var plan_child = document.createElement('div');
                var str = "<div class=\"data_row\" style=\"margin-top: 5px\">\n" +
                    "                <div style=\"padding-left: 10px;width: 120px;display: inline-block;\">\n" +
                    "                    <div style=\"border-bottom: 1px solid;\">\n" +
                    "                        <div style=\"font-size: 12px;display: inline-block;width:55px;border-right: 1px solid black;text-align: right\" id=\"yw_left_top\">" + arr[i].leftUp + "</div><!--\n" +
                    "                        --><div style=\"font-size: 12px;display: inline-block;width:55px;\" id=\"yw_right_top\">" + arr[i].rightUp + "</div>\n" +
                    "                    </div>\n" +
                    "                    <div>\n" +
                    "                        <div style=\"font-size: 12px;display: inline-block;width:55px;border-right: 1px solid black;text-align: right\" id=\"yw_left_bottom\">" + arr[i].leftDown + "</div><!--\n" +
                    "                        --><div style=\"font-size: 12px;display: inline-block;width:55px;\" id=\"yw_right_bottom\">" + arr[i].rightDown + "</div>\n" +
                    "                    </div>\n" +
                    "                </div>\n" +
                    "                <div style=\"width: 140px;display: inline-block;position: relative;top: -5px;\" id=\"disposal\">" + arr[i].payServiceName + "</div>\n" +
                    "                <div style=\"width: 45px;display: inline-block;position: relative;top: -5px;\" id=\"number\">" + arr[i].payServiceNum + "</div>\n" +
                    "                <div style=\"width: 100px;display: inline-block;position: relative;top: -5px;\" id=\"unit\">" + arr[i].unit + "</div>\n" +
                    "                <div style=\"width: 100px;display: inline-block;position: relative;top: -5px;\" id=\"price\">" + arr[i].payService + "</div>\n" +
                    "                <div style=\"width: 100px;display: inline-block;position: relative;top: -5px;\" id=\"amount\">" + parseFloat(arr[i].payServiceNum) * parseFloat(arr[i].payService) + "</div>\n" +
                    "            </div>";
                plan_child.innerHTML = str;
                plan_box.appendChild(plan_child);
                money_all += parseFloat(arr[i].payServiceNum) * parseFloat(arr[i].payService);
                hjys_money += parseFloat(arr[i].foldingPay);
                bcqk_money = parseFloat(arr[i].accountArrears);
                doctor.innerText += arr[i].doctor + " ";
            }
            hjys.innerText = hjys_money.toFixed(2);
            bcqk.innerText = bcqk_money.toFixed(2);
            var zkjes = parseFloat(money_all).toFixed(2) - parseFloat(hjys_money).toFixed(2);
            zkje.innerText = zkjes.toFixed(2);
            bcfy.innerText = money_all.toFixed(2);
            $.ajax({
                url: Feng.ctxPath + "/consultant/getCheckoutMethod",
                type: "post",
                data: {
                    "operationTime": operationTime,
                    "reservationsId": reservationsId,
                    "customerId": customerId
                },
                success: function (data1) {
                    console.log(data1);
                    var str = "";
                    for (var k = 0; k < data1.length; k++) {
                        str += data1[k].checkoutMethod + " " + data1[k].actualAccountBalance.toFixed(2);
                        ssje_money += parseFloat(data1[k].actualAccountBalance).toFixed(2);
                        documentNumber.innerText = data1[k].documentNumber;
                    }
                    skfs.innerText = str;
                    ssje.innerText = ssje_money.toFixed(2);
                    zkl.innerText = ((parseFloat(hjys_money) / parseFloat(money_all)) * 100).toFixed(2);
                },
                error: function (data1) {
                    alert('内部故障！请联系管理员！');
                }
            });
        },
        error: function (data) {
            alert('内部故障！请联系管理员！');
        }
    });


    //打印代码
    var bt = document.getElementById("bt");
    var div_print = document.getElementById("div_print");
    bt.onclick = function () {
        printdiv(div_print);
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    };

    function printdiv(printpage) {
        var newstr = printpage.innerHTML;
        var oldstr = document.body.innerHTML;
        document.body.innerHTML = newstr;
        window.print();
        document.body.innerHTML = oldstr;
        console.log('打印成功');
        return false;
    }

</script>
@}
